package masterjava.common.client.gwt.rpc;

import com.google.gwt.core.client.GWT;
import com.google.gwt.user.client.rpc.AsyncCallback;
import masterjava.common.client.gwt.ExceptionHandler;

/**
 * User: Grigory Kislin
 * Date: 30/06/11
 * <p/>
 * Common callback should implement this adapter
 */
abstract public class CallbackAdapter<T> implements AsyncCallback<T> {

    @Override
    public void onFailure(Throwable e) {
        ExceptionHandler.treatException("Server communication exception", e);
    }

    @Override
    public void onSuccess(T result) {
        GWT.log("Server request received: " + result.getClass().getName());
        process(result);
    }

    protected abstract void process(T result);
}
